<template>
  <div id="app">
    <!-- 顶通栏 -->
    <Topbar :key="tobarKey"></Topbar>
    <!-- 头部 -->
    <Header></Header>
    <!-- 主页内容 -->
    <router-view @ShowCartsFn="ShowCartsFn" />
    <!-- 尾部 -->
    <Footer></Footer>
    <!-- 登录组件 -->
    <Login v-show="isShowLoginModal"></Login>
    <!-- <div class="iconfont icon-toast-jinggao"></div> -->
    <transition name="slide">
      <Toast v-show="isShowToast"></Toast>
    </transition>
  </div>
</template>
<script>
import Footer from "@/components/Footer.vue";
import Header from "@/components/Header.vue";
import Topbar from "@/components/Topbar.vue";
import Login from "@/components/Longin.vue";
import Toast from "@/components/Toast.vue";
import { JinpinAPI } from "@/request/api";
import { mapState } from "vuex";

export default {
  components: {
    Footer,
    Header,
    Topbar,
    Login,
    Toast,
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModel.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },
  data() {
    return {
      tobarKey: 0,
    };
  },

  created() {
    console.log(process.env.VUE_APP_BASE_URL);
    console.log(process.env.VUE_APP_TEXT);
  },
  watch: {
    "$route.path": {
      handler(newVal, oldVal) {
        if (newVal != oldVal) {
          this.tobarKey++;
        }
      },
    },
  },
  methods: {
    ShowCartsFn() {
      this.tobarKey++;
    },
  },
};
</script>
<style lang="less">
#app {
  // background-color: pink;
}

.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
